import request from '@/utils/request.js'

// 文章 - 获取单个文章详情
export const getArticleDetailAPI = ({
  id
}) => request({
  url: `/v1_0/articles/${id}`,
  method: 'GET'
})
// 文章 - 取消关注用户
export const userUnFollowAPI = ({
  userId
}) => request({
  url: `/v1_0/user/followings/${userId}`,
  method: 'DELETE'
})

// 文章 - 关注用户
export const userFollowAPI = ({
  userId
}) => request({
  url: '/v1_0/user/followings',
  method: 'POST',
  data: {
    target: userId
  }
})

// 文章 - 点赞
export const userLikeAPI = ({
  artId
}) => request({
  url: '/v1_0/article/likings',
  method: 'POST',
  data: {
    target: artId
  }
})

// 文章 - 取消点赞
export const userUnLikeAPI = ({
  artId
}) => request({
  url: `/v1_0/article/likings/${artId}`,
  method: 'DELETE'
})

// 评论 - 获取评论列表
export const getCommentListAPI = ({
  type,
  art_id,
  last_id = null,
  limit = 10
}) => request({
  url: '/v1_0/comments',
  method: 'GET',
  params: {
    type,
    source: art_id,
    offset: last_id,
    limit
  }
})

// 评论 - 点赞
export const commentLikeAPI = ({
  id
}) => request({
  url: '/v1_0/comment/likings',
  method: 'POST',
  data: {
    target: id
  }
})

// 评论 - 取消点赞
export const commentUnLikeAPI = ({
  id
}) => request({
  url: `/v1_0/comment/likings/${id}`,
  method: 'DELETE'
})

// 评论 - 发布评论
export const postCommentAPI = ({
  id,
  content
}) => request({
  url: '/v1_0/comments',
  method: 'POST',
  data: {
    target: id,
    content
  }
})
